<?php
error_reporting(E_ALL ^ E_NOTICE);

set_time_limit(0);
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("devildark", $con);
$dateTime = date("Y-m-d",strtotime("-1 day"));

    $deviceid_query = mysql_query("select  deviceid,date,TIME_TO_SEC(DailyGamingTime) as day,TIME_TO_SEC(GamingTime)  as total from devildark_query_temp "); //id
    //$deviceid = mysql_fetch_array($deviceid_query);
    //while($deviceid[deviceid])

while($deviceid = mysql_fetch_array($deviceid_query))
{
   mysql_query("REPLACE INTO devildark_query_temp_filter (deviceid,date,DailyGamingTime,GamingTime) 
                    VALUES('$deviceid[deviceid]','$deviceid[date]','$deviceid[day]','$deviceid[total]')") or die(mysql_error());
}

  // {
    //$first_query = mysql_query("SELECT RegisterDate FROM devildark where deviceid = '$deviceid[deviceid]' limit 0,1 ");

   // $first = mysql_fetch_array($first_query);
   mysql_query("update devildark a1 inner join devildark_query_temp_filter a2 using(deviceid) set a1.DailyGamingTime =a2.DailyGamingTime,a1.GamingTime =a2.GamingTime where a1.deviceid =  a2.deviceid and a1.date =  a2.date");
  //var_dump($deviceid[deviceid]);die;
//
  // }

//mysql_query("delete from devildark where TotalExp = ''");
mysql_close($con);
?>